package com.epoint.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.epoint.common.Result;
import com.epoint.service.BorrowInfoService;

/**
 * Servlet implementation class BorrowInfoDelAction
 */
@WebServlet("/borrowinfodelaction")
public class BorrowInfoDelAction extends HttpServlet {
	private static final long serialVersionUID = 1L;
    BorrowInfoService borrowInfoService = new BorrowInfoService();
    /**
     * @see HttpServlet#HttpServlet()
     */
    public BorrowInfoDelAction() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String ids = request.getParameter("ids");
		String[] borrowIds = ids.split(",");
		
		int flag = 0;
		for(String borrowId : borrowIds) {
			flag = borrowInfoService.deleteBorrowInfo(borrowId);
		}
		String returnCode = Result.returnCode(flag);
		response.getWriter().print(returnCode);
	}

}
